﻿@using Kojarskiy.Models
@using Kojarskiy.Core
@model IEnumerable<Kojarskiy.Models.News>

@{
    var context = new KojarskiyDbEntities();
    ViewBag.Title = "Новости и статьи";
}
@Html.ActionLink("Администрирование", "Index", "Admin") | @ViewBag.Title
<div style="clear: both;"></div>

<h1 class="f_l">@ViewBag.Title</h1>

<div class="form-group f_r">
    <button class="btn btn-sm btn-success" type="button" onclick="location.href='@Url.Action("Create", "News")'">
        Добавить новость или статью
    </button>
</div>
<table class="table table-striped table-hover">
    <tr>
        <th>Дата</th>
        <th>Заголовок новости</th>
        <th>Title</th>
        <th>Description</th>
        <th>Keywords</th>
        <th></th>
    </tr>
    @foreach (var item in Model)
    {
        <tr>
            <td>@item.PublicationDate.ToString()</td>
            <td>@Html.ActionLink(item.Name,"Details", new{id = item.NewsId})</td>
            <td>@item.Title</td>
            <td>@item.Description</td>
            <td>@item.Keywords</td>
            <td>

                <button class="btn btn-xs btn-warning" type="button" onclick="location.href='@Url.Action("Edit", "News", new { id = item.NewsId })'">
                    Редактировать
                </button>
                <button class="btn btn-xs btn-danger" type="button" onclick="location.href='@Url.Action("Delete", "News", new { id = item.NewsId })'">
                    Удалить
                </button>

            </td>
        </tr>
    }
</table>